home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / jce.jar / javax / crypto / ExemptionMechanism.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-07-27  |  3.2 KB  |  127 lines

  1. package javax.crypto;
  2.  
  3. import java.security.AlgorithmParameters;
  4. import java.security.InvalidAlgorithmParameterException;
  5. import java.security.InvalidKeyException;
  6. import java.security.Key;
  7. import java.security.NoSuchAlgorithmException;
  8. import java.security.NoSuchProviderException;
  9. import java.security.Provider;
  10. import java.security.spec.AlgorithmParameterSpec;
  11. import sun.security.jca.GetInstance;
  12.  
  13. public class ExemptionMechanism {
  14.    private Provider provider;
  15.    private ExemptionMechanismSpi exmechSpi;
  16.    private String mechanism;
  17.    private boolean done = false;
  18.    private boolean initialized = false;
  19.    private Key keyStored = null;
  20.  
  21.    protected ExemptionMechanism(ExemptionMechanismSpi var1, Provider var2, String var3) {
  22.       this.exmechSpi = var1;
  23.       this.provider = var2;
  24.       this.mechanism = var3;
  25.    }
  26.  
  27.    public final String getName() {
  28.       return this.mechanism;
  29.    }
  30.  
  31.    public static final ExemptionMechanism getInstance(String var0) throws NoSuchAlgorithmException {
  32.       GetInstance.Instance var1 = SunJCE_b.a("ExemptionMechanism", ExemptionMechanismSpi.class, var0);
  33.       return new ExemptionMechanism((ExemptionMechanismSpi)var1.impl, var1.provider, var0);
  34.    }
  35.  
  36.    public static final ExemptionMechanism getInstance(String var0, String var1) throws NoSuchAlgorithmException, NoSuchProviderException {
  37.       GetInstance.Instance var2 = SunJCE_b.a("ExemptionMechanism", ExemptionMechanismSpi.class, var0, var1);
  38.       return new ExemptionMechanism((ExemptionMechanismSpi)var2.impl, var2.provider, var0);
  39.    }
  40.  
  41.    public static final ExemptionMechanism getInstance(String var0, Provider var1) throws NoSuchAlgorithmException {
  42.       GetInstance.Instance var2 = SunJCE_b.a("ExemptionMechanism", ExemptionMechanismSpi.class, var0, var1);
  43.       return new ExemptionMechanism((ExemptionMechanismSpi)var2.impl, var2.provider, var0);
  44.    }
  45.  
  46.    public final Provider getProvider() {
  47.       return this.provider;
  48.    }
  49.  
  50.    public final boolean isCryptoAllowed(Key var1) throws ExemptionMechanismException {
  51.       boolean var2 = false;
  52.       if (this.done && var1 != null) {
  53.          var2 = this.keyStored.equals(var1);
  54.       }
  55.  
  56.       return var2;
  57.    }
  58.  
  59.    public final int getOutputSize(int var1) throws IllegalStateException {
  60.       if (!this.initialized) {
  61.          throw new IllegalStateException("ExemptionMechanism not initialized");
  62.       } else if (var1 < 0) {
  63.          throw new IllegalArgumentException("Input size must be equal to or greater than zero");
  64.       } else {
  65.          return this.exmechSpi.engineGetOutputSize(var1);
  66.       }
  67.    }
  68.  
  69.    public final void init(Key var1) throws InvalidKeyException, ExemptionMechanismException {
  70.       this.done = false;
  71.       this.initialized = false;
  72.       this.keyStored = var1;
  73.       this.exmechSpi.engineInit(var1);
  74.       this.initialized = true;
  75.    }
  76.  
  77.    public final void init(Key var1, AlgorithmParameterSpec var2) throws InvalidKeyException, InvalidAlgorithmParameterException, ExemptionMechanismException {
  78.       this.done = false;
  79.       this.initialized = false;
  80.       this.keyStored = var1;
  81.       this.exmechSpi.engineInit(var1, var2);
  82.       this.initialized = true;
  83.    }
  84.  
  85.    public final void init(Key var1, AlgorithmParameters var2) throws InvalidKeyException, InvalidAlgorithmParameterException, ExemptionMechanismException {
  86.       this.done = false;
  87.       this.initialized = false;
  88.       this.keyStored = var1;
  89.       this.exmechSpi.engineInit(var1, var2);
  90.       this.initialized = true;
  91.    }
  92.  
  93.    public final byte[] genExemptionBlob() throws IllegalStateException, ExemptionMechanismException {
  94.       if (!this.initialized) {
  95.          throw new IllegalStateException("ExemptionMechanism not initialized");
  96.       } else {
  97.          byte[] var1 = this.exmechSpi.engineGenExemptionBlob();
  98.          this.done = true;
  99.          return var1;
  100.       }
  101.    }
  102.  
  103.    public final int genExemptionBlob(byte[] var1) throws IllegalStateException, ShortBufferException, ExemptionMechanismException {
  104.       if (!this.initialized) {
  105.          throw new IllegalStateException("ExemptionMechanism not initialized");
  106.       } else {
  107.          int var2 = this.exmechSpi.engineGenExemptionBlob(var1, 0);
  108.          this.done = true;
  109.          return var2;
  110.       }
  111.    }
  112.  
  113.    public final int genExemptionBlob(byte[] var1, int var2) throws IllegalStateException, ShortBufferException, ExemptionMechanismException {
  114.       if (!this.initialized) {
  115.          throw new IllegalStateException("ExemptionMechanism not initialized");
  116.       } else {
  117.          int var3 = this.exmechSpi.engineGenExemptionBlob(var1, var2);
  118.          this.done = true;
  119.          return var3;
  120.       }
  121.    }
  122.  
  123.    protected void finalize() {
  124.       this.keyStored = null;
  125.    }
  126. }
  127.